load("//bazel:skia_rules.bzl", "skia_cc_library", "skia_objc_library")

package(
    default_applicable_licenses = ["//:license"],
)

licenses(["notice"])

skia_cc_library(
    name = "skshaper_core",
    srcs = [
        "//modules/skshaper/src:core_srcs",
    ],
    hdrs = [
        "//modules/skshaper/include:core_hdrs",
    ],
    defines = ["SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS"],
    features = ["layering_check"],
    local_defines = ["SKSHAPER_IMPLEMENTATION=1"],
    visibility = [
        "//modules/skottie:__subpackages__",
        "//modules/svg:__subpackages__",
    ],
    deps = [
        "//:core",
        "//src/base",
        "//src/core:core_priv",
    ],
)

# This is its own library to make it harder for Skia itself to unintentionally
# include FactoryHelpers.h in utils
skia_cc_library(
    name = "skshaper_core_and_utils",
    hdrs = [
        "//modules/skshaper/include:core_hdrs",
        "//modules/skshaper/utils:core_hdrs",
    ],
    local_defines = ["SKSHAPER_IMPLEMENTATION=1"],
    visibility = [
        "//:__pkg__",
    ],
    deps = [
        ":skshaper_core",
    ],
)

skia_objc_library(
    name = "skshaper_coretext",
    srcs = [
        "//modules/skshaper/src:coretext_srcs",
    ],
    hdrs = [
        "//modules/skshaper/include:core_hdrs",
        "//modules/skshaper/include:coretext_hdrs",
        "//modules/skshaper/utils:core_hdrs",
    ],
    copts = ["-DSKSHAPER_IMPLEMENTATION=1"],
    defines = [
        "SK_SHAPER_CORETEXT_AVAILABLE",
        "SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS",
    ],
    features = ["layering_check"],
    ios_frameworks = [
        "CoreText",
        "CoreGraphics",
        "CoreFoundation",
    ],
    mac_frameworks = ["ApplicationServices"],
    visibility = [
        "//:__subpackages__",
    ],
    deps = [
        ":skshaper_core",
        "//:core",
        "//src/base",
        "//src/core:core_priv",
        "//src/ports:coretext_typeface",
        "//src/utils/mac:mac_utils_priv",
    ],
)

skia_cc_library(
    name = "skshaper_harfbuzz",
    srcs = [
        "//modules/skshaper/src:harfbuzz_srcs",
    ],
    hdrs = [
        "//modules/skshaper/include:core_hdrs",
        "//modules/skshaper/include:harfbuzz_hdrs",
        "//modules/skshaper/utils:core_hdrs",
    ],
    defines = [
        "SK_SHAPER_HARFBUZZ_AVAILABLE",
        "SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS",
    ],
    features = ["layering_check"],
    local_defines = ["SKSHAPER_IMPLEMENTATION=1"],
    visibility = [
        "//:__subpackages__",
    ],
    deps = [
        ":skshaper_core",
        "//:core",
        "//modules/skunicode:skunicode_core",
        "//src/base",
        "//src/core:core_priv",
    ] +
    # We have this harfbuzz dependency all by itself because we need to turn this into a
    # select statement when rolling into G3.
    [
        "@harfbuzz",
    ],
)

skia_cc_library(
    name = "skshaper_unicode",
    srcs = [
        "//modules/skshaper/src:skunicode_srcs",
    ],
    hdrs = [
        "//modules/skshaper/include:core_hdrs",
        "//modules/skshaper/include:skunicode_hdrs",
        "//modules/skshaper/utils:core_hdrs",
    ],
    defines = [
        "SK_SHAPER_UNICODE_AVAILABLE",
        "SK_DISABLE_LEGACY_SKSHAPER_FUNCTIONS",
    ],
    features = ["layering_check"],
    local_defines = ["SKSHAPER_IMPLEMENTATION=1"],
    visibility = [
        "//:__subpackages__",
    ],
    deps = [
        ":skshaper_core",
        "//:core",
        "//modules/skunicode:skunicode_core",
        "//src/base",
        "//src/core:core_priv",
    ],
)
